<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/myOrder1.css">
<script type="text/javascript">

	$(function() {

		//初始化页面配置
		initPage("订单", "order");
		var app = new Vue({
			el: '#container',
			data: {
				orderList: [],
			},
			methods: {
				index: indexPage,
				order: orderPage,
				rank: rankPage,
				center: centerPage,
				indexOrder: function() {
					window.location.href = "/wechat/order/index";
				}
			}
		})

		var pageNum = 2;
		var isNeedRefresh = false;

		$(window).scroll(function(){
			var scrollTop = $(this).scrollTop();
			var scrollHeight = $(document).height();
			var windowHeight = $(this).height();
			if(!isNeedRefresh &&
					(scrollHeight - scrollTop - windowHeight <= 25)){
				isNeedRefresh = true;
				refreshPage(pageNum++);
			}
		});

		function refreshPage(pageNum) {
			$.ajax({
				url:"/wechat/order/orderList",
				type:"post",
				data:{
					status: "end",
					pageNum: pageNum,
				},
				dataType:"JSON",
				beforeSend:function(){
					$("#loadingToast").show();
				},
				complete:function(){
					$('#loadingToast').hide();
				},
				success:function(data){
					if(!isNullOrEmpty(data)) {
						app.orderList = app.orderList.concat(data);
						isNeedRefresh = false;
					}
				},
			})
		}

		$.ajax({
			url:"/wechat/order/orderList",
			type:"post",
			data:{
				status: "end",
				pageNum:1,
			},
			dataType:"JSON",
			beforeSend:function(){
				$("#loadingToast").show();
			},
			complete:function(){
				$('#loadingToast').hide();
			},
			success:function(data){
				app.orderList = data;
			},
		})

	});


</script>
<div class="my-order">
	<div class="choose-header">
		<div class="choose-order-type">
			<div class="now" v-on:click="indexOrder"><span>进行中</span></div>
			<div class="complete active"><span>已完成</span></div>
		</div>
	</div>
	<div class="has-no-order" v-if="orderList == null">暂无订单</div>
	<div class="my-order-list" v-for="order in orderList">
		<div class="my-order-bingo">
			<div class="header-name color-99">团长：{{order.group_name}}</div>
			<div class="progress color-99" v-if="(order.status == 5 && order.winner_customer_id != order.customer_id)">
				<span>团胜</span> | 未获奖
			</div>
			<div class="progress color-99" v-if="(order.status == 5 && order.winner_customer_id == order.customer_id)">
				<span>团胜 | 中奖</span>
			</div>
			<div class="progress color-99" v-if="(order.status == 4)">团灭</div>
			<div class="goods">
				<div class="goods-img" style="background: url('{{order.image}}')no-repeat center;background-size: cover;"></div>
				<div class="goods-info">
					<p class="title color-font">{{order.product_name}}</p>
					<p class="time color-99">下单时间：{{order.create_time}}</p>
					<p class="price color-99">总价：{{order.price}}</p>
				</div>
				<div class="my-pay-price color-font">{{order.number}}</div>
				<div class="my-pay-num color-99">{{order.number}}份</div>
			</div>
			<p class="result color-99" v-if="(order.status == 5 && order.winner_customer_id == order.customer_id && order.pie_type == 2)">选择补差价领取奖品</p>
			<p class="result color-99" v-if="(order.status == 5 && order.pie_type == 1)">全团瓜分奖金 <span class="color-font">{{order.reward}}</span></p>
			<p class="result color-99" v-if="(order.status == 5 && order.winner_customer_id != order.customer_id && order.pie_type == 2)">获得奖金 <span class="color-font">{{order.reward}}</span></p>
		</div>
	</div>
</div>